//
//  Crowdfund TableViewCell.swift
//  XMYouPin
//
//  Created by 王宗成 on 2019/7/7.
//  Copyright © 2019 王宗成. All rights reserved.
//

import UIKit

class Crowdfund_TableViewCell: WZC_TableViewCell {

    lazy var leftLable: UILabel = {
        
        let lable = UILabel()
        lable.text = "小米众筹"
        lable.textColor = .black
        lable.font = BFont(19)
        self.contentView.addSubview(lable)
        return lable
    }()
    
    lazy var rightLable: UILabel = {
        
        let lable = UILabel()
        lable.text = "更多"
        lable.textColor = UIColor.red
        lable.font = Font(14)
        self.contentView.addSubview(lable)
        return lable
    }()
    
    lazy var rightImgView: UIImageView = {
        
        let imgView:UIImageView = UIImageView()
        imgView.image = IMAGE("mjyp_mainPage_more_arrow")
        self.contentView.addSubview(imgView)
        return imgView
    }()
    
    lazy var topView: CrowdfundSubView = {
        
        let view:CrowdfundSubView = CrowdfundSubView()
        view.location = 0;
        self.contentView.addSubview(view)
        return view
    }()
    lazy var leftView: CrowdfundSubView = {
        
        let view:CrowdfundSubView = CrowdfundSubView()
        view.location = 1;
        self.contentView.addSubview(view)
        return view
    }()
    lazy var rightView: CrowdfundSubView = {
        
        let view:CrowdfundSubView = CrowdfundSubView()
        view.location = 1;
        self.contentView.addSubview(view)
        return view
    }()
    
    var model:HomeFloorModel?
    {
        didSet
        {
            self.topView.model = self.model?.data?.items[0]
            self.leftView.model = self.model?.data?.items[1]
            self.rightView.model = self.model?.data?.items[2]
        }
    }
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.contentView.backgroundColor = .white
        
        self.leftLable.snp.makeConstraints { (make) in
            
            make.left.equalTo(10)
            make.top.equalTo(20*kHeightRatio)
            make.height.equalTo(24)
        }
        
        self.rightImgView.snp.makeConstraints { (make) in
            
            make.right.equalTo(-10)
            make.centerY.equalTo(self.leftLable.snp_centerY)
        }

        self.rightLable.snp.makeConstraints { (make) in

            make.right.equalTo(self.rightImgView.snp_left).offset(-5)
            make.centerY.equalTo(self.leftLable.snp_centerY)
        }
        
        self.topView.snp.makeConstraints { (make) in

            make.top.equalTo(64*kHeightRatio)
            make.height.equalTo(140*kHeightRatio)
            make.left.equalTo(10)
            make.width.equalTo(kScreenW-20)
        }

        self.leftView.snp.makeConstraints { (make) in

            make.top.equalTo(self.topView.snp_bottom)
            make.height.equalTo(140*kHeightRatio)
            make.width.equalTo((kScreenW-10*2 - 3)/2)
            make.left.equalTo(10)
        }
        self.rightView.snp.makeConstraints { (make) in

            make.top.equalTo(self.topView.snp_bottom)
            make.height.equalTo(140*kHeightRatio)
            make.width.equalTo((kScreenW-10*2 - 3)/2)
            make.left.equalTo(self.leftView.snp_right).offset(3)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
